import { _decorator, Component, Constructor, instantiate, Node, Prefab } from 'cc';
import { GameState } from './config/game-param';
const { ccclass, property } = _decorator;

@ccclass('UICtrl')
export class UICtrl extends Component {
    private static _instance: UICtrl = null

    static get instance(): UICtrl {
        return this._instance
    }

    onLoad() {
        UICtrl._instance = this
    }
    
    open(prefab: Prefab) {
        const uiNode = instantiate(prefab)
        this.node.addChild(uiNode)
    }

    closed(name: string) {
        this.node.children.forEach(child => {
            if (child.name === name) this.node.getChildByName(name).destroy()
        })
    }
}


